/*
 * KeepAliveSender.cpp
 *
 *  Created on: 20/06/2014
 *      Author: Vitor
 */

#include "KeepAliveSender.h"

KeepAliveSender::KeepAliveSender() :
		socket(UDPSocket(0)) {
}

KeepAliveSender::~KeepAliveSender() {
}

void KeepAliveSender::run() {
	std::vector<char> keep_alive_message;
	keep_alive_message.push_back(MessageTypes::KEEP_ALIVE);

	while (Globals::active.get()) {
		socket.send(keep_alive_message, "255.255.255.255", 3759);

		SDL_Delay(KEEP_ALIVE_PERIOD + (rand() % 1000));
	}
}
